<?php
require("config.php");

if (isset($_POST['getLocMap'])) {
	require("MapService.php");
}
elseif (isset($_POST['returnCar'])) {
	require("return.php");
}
else {
/* test-code: */
/*
	$cars = array();
	$cars[] = array(
	"license" => "W-12345",
	"name" => "Ford Prefect"
	);
*/
    $cars = $CarService->getAllCars();
	
	$carsAvail = array();
	$carsRent = array();
	
	//var_dump($cars);
	
	foreach ($cars->item as $val) {
		if (!$val->verliehen) {
			$carsAvail[] = array(
				"typ" => $val->typ,
				"kennzeichen" => $val->kennzeichen
			);
		}
		else {
			$carsRent[] = array(
				"typ" => $val->typ,
				"kennzeichen" => $val->kennzeichen
			);
		}
	}
	
	$smarty->assign('carsAvail', $carsAvail);
	$smarty->assign('carsRent', $carsRent);
	$smarty->display('index.tpl');
}
?>